﻿<%@ Page Title="" Language="C#" MasterPageFile="~/masterpage_user.master" AutoEventWireup="true" CodeFile="editQLTinNhan.aspx.cs" Inherits="editQLTinNhan" %>

<asp:Content ID="Content1" ContentPlaceHolderID="user_content" Runat="Server">
    <div class="title">Quản Lý Tin Nhắn</div>
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
        CellPadding="4" DataKeyNames="Matinnhan" DataSourceID="SqlDataSource1" 
        Font-Names="Arial" ForeColor="#507CD1" GridLines="None" Height="50px" 
        HorizontalAlign="Center" Width="700px"
        onpageindexchanging="DetailsView1_PageIndexChanging" CssClass="table-a">
        <AlternatingRowStyle BackColor="White" />
        <CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
        <EditRowStyle BackColor="#507CD1" />
        <FieldHeaderStyle BackColor="#99CCFF" Font-Bold="True" ForeColor="White" 
            HorizontalAlign="Left" VerticalAlign="Middle" />
        <Fields>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:Button ID="Button1" runat="server" CausesValidation="True" 
                        CommandName="Update" Text="Cập nhật" />
                    &nbsp;<asp:Button ID="Button2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" Text="Hủy" />
                </EditItemTemplate>
                <InsertItemTemplate>
                    &nbsp;
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Button ID="Button1" runat="server" CausesValidation="False" 
                        CommandName="Edit" Text="Sửa" />
                    &nbsp;<asp:Button ID="btQuayLai" runat="server" onclick="btQuayLai_Click" 
                        Text="Quay lại" />
                </ItemTemplate>
                <ItemStyle BackColor="#99CCFF" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Mã Tin Nhắn" SortExpression="Matinnhan">
                <EditItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Matinnhan") %>' 
                        Font-Names="Arial" ForeColor="White"></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Matinnhan") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle Font-Bold="False" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Username" SortExpression="Username">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" 
                        DataSourceID="SqlDataSource2" DataTextField="Hoten" DataValueField="Username" 
                        SelectedValue='<%# Bind("Username") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Username") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Người Nhận" SortExpression="Nguoinhan">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Nguoinhan") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("Nguoinhan") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Tiêu Đề" SortExpression="Tieude">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Tieude") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("Tieude") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Ngày Gửi" SortExpression="Ngaygoi">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Ngaygoi") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("Ngaygoi") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Nội Dung" SortExpression="Noidungtinnhan">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("Noidungtinnhan") %>' 
                        Height="269px" TextMode="MultiLine" Width="477px"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:TextBox ID="TextBox7" runat="server" Font-Names="Arial" Font-Size="Medium" 
                        ForeColor="#507CD1" Height="269px" ReadOnly="True" 
                        Text='<%# Bind("Noidungtinnhan") %>' TextMode="MultiLine" Width="477px"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
        </Fields>
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" 
            HorizontalAlign="Center" VerticalAlign="Middle" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
    </asp:DetailsView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:chodientuConnectionString %>" 
        DeleteCommand="DELETE FROM Tinnhan WHERE (Matinnhan = @Matinnhan)" 
        SelectCommand="SELECT * FROM [Tinnhan] WHERE ([Matinnhan] = @Matinnhan)" 
        
        
        
        
        
        UpdateCommand="UPDATE Tinnhan SET Username = @Username, Tieude = @Tieude, Nguoinhan = @Nguoinhan, Ngaygoi = @Ngaygoi, Noidungtinnhan = @Noidungtinnhan WHERE (Matinnhan = @Matinnhan)">
        <DeleteParameters>
            <asp:Parameter Name="Matinnhan" />
        </DeleteParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="TextBox1" ConvertEmptyStringToNull="False" 
                Name="Matinnhan" PropertyName="Text" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Username" />
            <asp:Parameter Name="Tieude" />
            <asp:Parameter Name="Nguoinhan" />
            <asp:Parameter Name="Ngaygoi" />
            <asp:Parameter Name="Noidungtinnhan" />
            <asp:Parameter Name="Matinnhan" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:chodientuConnectionString %>" 
        SelectCommand="SELECT * FROM [Thanhvien] WHERE ([Username] = @Username)">
        <SelectParameters>
            <asp:SessionParameter Name="Username" SessionField="User" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:TextBox ID="TextBox1" runat="server" Visible="False"></asp:TextBox>
</asp:Content>

